package com.yc.spring.test;

import com.yc.spring.vote.VoteConfig;
import com.yc.spring.vote.biz.VoteBiz;
import com.yc.spring.vote.dao.VoteDao;
import com.yc.spring.vote.web.VoteAction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

// Junit 将测试驱动交个 SpringRunner 执行
@RunWith(SpringRunner.class)
// 设置Spring配置类
@ContextConfiguration(classes = VoteConfig.class)
public class SpringTest1 {

    @Autowired
    VoteBiz biz;
    @Autowired
    VoteAction action;
    @Resource  // 使用当前的变量名, 作为id从容器中获取bean
    VoteDao vDao;
    @Resource
    VoteDao voteDao;

    // 4个组件注解,默认使用类名首字母小写, 作为 id

    @Test
    public void test1(){
        System.out.println("biz = " + biz);
        System.out.println("vDao = " + vDao);
        System.out.println("voteDao = " + voteDao);
        System.out.println("action = " + action);
    }

}
